import grails.test.*

class BookProfileTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testBookProfileCreation() {
        BookProfile existingBook = new BookProfile(name:"fight club")
        mockDomain(BookProfile, [existingBook])
		
		BookProfile book = new BookProfile()
        assertFalse book.validate()
        
        assertEquals "nullable", book.errors["name"]

        book.name=" "
        assertFalse book.validate()
        assertEquals "blank", book.errors["name"]

        book.name='Fight Club'
        assertFalse book.validate()
        assertEquals 'validator', book.errors['name']

        book.name="longerthan100" + 'x'*88
        assertFalse book.validate()
        assertEquals 'maxSize', book.errors["name"]

        book.name="longerthan100" + 'x'*87
        assertTrue book.validate()
    }
}
